package com.andoridtools.dialog;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.andoridtools.R;


public class LoadingDailog {
    private Context context;

    public LoadingDailog(@NonNull Context context) {
        this.context = context;
        createDialog();
    }

    private void createDialog() {
        AlertDialog dialog = new AlertDialog.Builder(context, R.style.Dialog).create();

        dialog.show();
        dialog.setContentView(R.layout.loading_dialog);
        dialog.setCanceledOnTouchOutside(true);

        Window dialogWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.CENTER);
        lp.width = 240;
        lp.height = 240;
        dialogWindow.setAttributes(lp);
    }

    public void show() {
        this.show();
    }

    public void dismiss() {
        this.dismiss();
    }
}
